import {DXMResponse} from "./common";
import { invoke } from "@tauri-apps/api/core";
const dxc_name = "UserService"
const dxc_version = "0.0.1"
export type BoolResponse = { 
  value: boolean, 
}
export type UserInfo = { 
  username: string, 
  password: string, 
  remember: boolean, 
}
export async function AddUser (param: UserInfo) { 
    const ret = await invoke("invoke_dxc", {
            invokeRequest: {
              dxc_name,
              dxc_version,
              api: "AddUser",
              params: param
            }
  });
  return ret as DXMResponse<{}>;
} 

export async function Login (param: UserInfo) { 
    const ret = await invoke("invoke_dxc", {
            invokeRequest: {
              dxc_name,
              dxc_version,
              api: "Login",
              params: param
            }
  });
  return ret as DXMResponse<{}>;
} 

export async function IsLogin () { 
    const ret = await invoke("invoke_dxc", {
            invokeRequest: {
              dxc_name,
              dxc_version,
              api: "IsLogin",
              params: {}
            }
  });
  return ret as DXMResponse<BoolResponse>;
} 

export async function GetRememberAccount () { 
    const ret = await invoke("invoke_dxc", {
            invokeRequest: {
              dxc_name,
              dxc_version,
              api: "GetRememberAccount",
              params: {}
            }
  });
  return ret as DXMResponse<UserInfo>;
} 

